package com.vanysoft.business.system.loginSettings.controller;

import com.vanysoft.business.sys.entity.UserInfo;
import com.vanysoft.business.system.loginSettings.controller.demo.LoginSetDemo;
import com.vanysoft.business.system.loginSettings.entity.TSystemLoginSet;
import com.vanysoft.business.system.loginSettings.service.LoginSettingService;
import com.vanysoft.framework.aop.VanySoftValidation;
import com.vanysoft.framework.base.action.BaseController;
import com.vanysoft.framework.config.mvc.SessionUser;
import com.vanysoft.framework.exception.VanySoftBaseException;
import com.vanysoft.framework.messagesource.MessageCodeConstant;
import com.vanysoft.framework.utils.JSONResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;


/**
 * 类名称：LoginSettingsAction
 * 类描述：登录设置
 * 创建人：X
 * 创建时间：2017年9月2日下午11:57:41
 * 修改人：X
 * 修改时间：2017年9月2日
 * 版本信息：@version 1.0
 * Copyright (c) 2017SharpClaw-版权所有
 * 修改备注：
 */
@RestController
@RequestMapping("/system/loginSet")
public class LoginSettingsAction extends BaseController {

    @Autowired
    private LoginSettingService loginSettingService;


    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @VanySoftValidation
    public JSONResponse addLoginSet(@SessionUser UserInfo userInfo, @Valid LoginSetDemo loginSet, BindingResult result) throws VanySoftBaseException {
        loginSettingService.addLoginSet(loginSet, userInfo);
        return new JSONResponse();
    }

    @RequestMapping(value = "/update", method = RequestMethod.POST)
    @VanySoftValidation
    public JSONResponse updateLoginSet(@SessionUser UserInfo userInfo, @Valid LoginSetDemo loginSet, BindingResult result) throws VanySoftBaseException {
        loginSettingService.updateLoginSet(loginSet, userInfo);
        return new JSONResponse();
    }

    @RequestMapping(value = "/query", method = RequestMethod.POST)
    public JSONResponse queryLicense() throws VanySoftBaseException {
        TSystemLoginSet obj = loginSettingService.queryLoginSet();
        return new JSONResponse(MessageCodeConstant.RTN_CODE_SUCCESS, obj);
    }
} 
